//
//  TextField.swift
//  BaseModule_Example
//
//  Created by seven on 2020/7/2.
//  Copyright © 2020 CocoaPods. All rights reserved.
//

import UIKit

public extension UITextField {
    
    var tt_font: CGFloat {
        set {
            self.font = UIFont.systemFont(ofSize: fit(newValue))
        }
        get {
            self.font?.pointSize ?? 0
        }
    }
    
}
/*
enum SSKeyboardType {
    case `default`
    case number
    case decimal
    case idCard(isNeedBlank: Bool)
    case bankCard(isNeedBlank: Bool)
    case mobile(isNeedBlank: Bool)
}

extension SSKeyboardType {
    /// 左下角按钮的title
    var customButtonTitle: String? {
        switch self {
        case .decimal: return "."
        case .idCard: return "X"
        default: return nil
        }
    }
    
    /// 是否需要加空格
    var isNeedBlank: Bool {
        switch self {
        case .idCard(let isNeed): return isNeed
        case .bankCard(let isNeed): return isNeed
        case .mobile(let isNeed): return isNeed
        default: return false
        }
    }
}

extension SSKeyboardType: Hashable, Equatable {
    

    /// 实现哈希协议
    func hash(into hasher: inout Hasher) {
        switch self {
        case .default:   return hasher.combine(0)
        case .number:    return hasher.combine(1)
        case .decimal:   return hasher.combine(2)
        case .idCard:    return hasher.combine(3)
        case .bankCard:  return hasher.combine(4)
        case .mobile:    return hasher.combine(5)
        }
    }
    
    /// 实现Equatable协议
    static func == (lhs: SSKeyboardType, rhs: SSKeyboardType) -> Bool {
        switch (lhs, rhs) {
        case (.default, .default):   return true
        case (.number, .number):     return true
        case (.decimal, .decimal):   return true
        case (.idCard, .idCard):     return true
        case (.bankCard, .bankCard): return true
        case (.mobile, .mobile):     return true
        default: return false
        }
    }
}


extension UITextField {
    
    private struct AssociatedKeys {
        /// 键盘类型
        static var keyboardType = "ss_uiTextView_keyboardType"
        
        /// 极值位数
        static var limit = "ss_uiTextView_limit"
        
        /// 如果键盘类型为浮点型，整数部分的极值位数
        static var integerLimit = "ss_uiTextView_integerLimit"
        
        /// 如果键盘类型为浮点型，小数部分的极值位数
        static var decimalLimit = "ss_uiTextView_decimalLimit"
        
        /// 是否显示收回键盘按钮
        static var dismissKeyboardEnable = "ss_uiTextView_dismissKeyboardEnable"
    }
    
    /// 键盘类型
    var ss_keyboardType: SSKeyboardType? {
        set {
            objc_setAssociatedObject(self, &type(of: self).AssociatedKeys.keyboardType, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
        get {
            return objc_getAssociatedObject(self, &type(of: self).AssociatedKeys.keyboardType) as? SSKeyboardType
        }
    }
    
    /// 极值位数
    var ss_limit: Int? {
        set {
            objc_setAssociatedObject(self, &type(of: self).AssociatedKeys.limit, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
        get {
            return objc_getAssociatedObject(self, &type(of: self).AssociatedKeys.limit) as? Int
        }
    }
    
    /// 如果键盘类型为浮点型，整数部分的极值位数
    var ss_integerLimit: Int? {
        set {
            objc_setAssociatedObject(self, &type(of: self).AssociatedKeys.integerLimit, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
        get {
            return objc_getAssociatedObject(self, &type(of: self).AssociatedKeys.integerLimit) as? Int
        }
    }
    
    /// 如果键盘类型为浮点型，小数部分的极值位数
    var ss_decimalLimit: Int? {
        set {
            objc_setAssociatedObject(self, &type(of: self).AssociatedKeys.decimalLimit, newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
        }
        get {
            return objc_getAssociatedObject(self, &type(of: self).AssociatedKeys.decimalLimit) as? Int
        }
    }
    
}
*/
